package ifSwitchPlugins;

import java.util.ArrayList;
import java.util.List;

//Defines the counter for the student count and the lists for students
//to be saved in
public class EdronProject {
	private              int           studentCount;
	private static final String        USAGE = "Usage: java EdronProject <student count>";
	private              List<Student> list;


	//Set up the counter fo the number of students and the list in which 
	//each student's information is saved once processed
	public EdronProject(int count) {
		studentCount = count;
		list = new ArrayList<Student>(); 
	}
	//Checks the number or arguments, and it executes the rest of the code 
	//if there is 1 argument or more (the number of arguments = the number 
	//of students being processed)
	public static void main( String args[] )  throws NumberFormatException {
		int count = 0;
		switch (args.length) {
		case 1: count = Integer.parseInt(args[0]); break;
		default: System.out.println(USAGE); 
		}
		//Defines method for processing and printing students within the 
		//EdronProject class  
		EdronProject edp = new EdronProject(count);
		edp.processStudents();
		edp.printStudents();
	}

	private void printStudents() {
		System.out.println("Print students");

	}
	private void processStudents() {
		System.out.println("Process students");
	}

	class Student {
		//Define integer values for the 5 subject's grades, the gradeCounter (used 
		//in the processing stage) and the student name string 
		private int  
		gradeCounter,
		grade1,
		grade2,
		grade3,
		grade4,
		grade5;

		private double total; 
		private String studentName;

		//Use setter getter methods for the student name to be retrieved
		public void setStudentName(String name) {
			studentName = name;

		}

		public String getStudentName() {
			return( studentName );
		}

		//Use setter getter methods for the grades inputted to be retrieved 
		//by the processing stage
		public void setGrade(int gradeNo, int grade)  throws IllegalArgumentException {
			switch( gradeNo) {
			case 1 : grade1 = grade; break;
			case 2 : grade2 = grade; break;
			case 3 : grade3 = grade; break;
			case 4 : grade4 = grade; break;
			case 5 : grade5 = grade; break;
			default: throw new IllegalArgumentException("ERROR: Bad grade number passed!");
			}
			//Increase grade counter for it to register the number of grades inputted
			//by user
			gradeCounter++; 
		}
		public int getGrade(int gradeNo)  throws IllegalArgumentException {
			int grade = 0;
			switch( gradeNo) {
			case 1 : grade = grade1; break;
			case 2 : grade = grade2; break;
			case 3 : grade = grade3; break;
			case 4 : grade = grade4; break;
			case 5 : grade = grade5; break;
			default: throw new IllegalArgumentException("ERROR: Bad grade number passed!");
			}
			//Return grade values for them to be used by the processing stage    
			return( grade );
		}
		//Calculate the total by adding al 5 grade values  
		public double getTotal() {  
			total = (getGrade(1) + getGrade(2) + getGrade(3) + getGrade(4) + getGrade(5));
			//Total value returned for it to be used to calculate the average    
			return total;
		}
		//Average is calculated by dividing the total over the grade 
		//counter (number of grades inputted)
		public double getAverage() {  
			return ( (gradeCounter == 0) ? 0 : total / gradeCounter);
		}
	}
}